package com.eric.windows.anima;

import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.eric.windows.R;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_my_animation)
public class MyAnimationActivity extends Activity {

    @ViewById(R.id.img_animation)
    ImageView img;
    @ViewById(R.id.btn_animation)
    Button button;
    private MyAnimation myAnimation;

    @AfterViews
    void initData(){
        DisplayMetrics metrics = new DisplayMetrics();
        Display display = getWindowManager().getDefaultDisplay();
        display.getMetrics(metrics);
        myAnimation = new MyAnimation(metrics.xdpi / 2, metrics.ydpi /2 ,1000);
        img.setAnimation(myAnimation);
    }

    @Click({R.id.btn_animation})
    public void onClick(View view){
        img.invalidate();
        Toast.makeText(this, "动画", Toast.LENGTH_SHORT).show();
    }


}
